package com.atguigu.test.dacahngmainshitidierji.reference;

import java.lang.ref.SoftReference;

/**
 * 2 * @Author: madonghui
 * 3 * @Date: 2020/11/23 17:29
 * 4
 */
public class SoftReferenceDemo {
    //enough够用    内存够用的情况下不会回收
    public static void softRef_Memory_Enough(){
        Object o = new Object();
        SoftReference<Object> objectSoftReference = new SoftReference<>(o);
        System.out.println(o);
        System.out.println(objectSoftReference.get());

        o = null;
        System.gc();

        System.out.println(o);
        System.out.println(objectSoftReference.get());
    }

    public static void softRef_Memory_NonEnough(){

    }

    public static void main(String[] args) {
        softRef_Memory_Enough();
    }
}
